home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 445 < prev    next >
Encoding:
Text File  |  1996-08-06  |  3.8 KB  |  118 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
  3. Newsgroups: comp.std.c++
  4. Subject: #error (was: Re: #warning)
  5. Date: 22 Feb 1996 10:14:55 PST
  6. Organization: Comp Sci, University of Melbourne
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4gibn8$6pg@mulga.cs.mu.OZ.AU>
  9. References: <4g91rh$kgn@mulga.cs.mu.OZ.AU> <4gdcvn$cqv@engnews1.Eng.Sun.COM>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: 22 Feb 1996 18:12:56 GMT
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMSyyzEy4NqrwXLNJAQGkKwH+NZP6XPPsaOKNpIb7B/RPYkaPwcRCVd5z
  14.     Kkb+au26uAAuEle9OwG8O9ZK9LdkRx8iqkAk9KdltE9bmqLs/KLM4Q==
  15.     =RW/c
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. clamage@Eng.sun.com (Steve Clamage) writes:
  19.  
  20. >fjh@munta.cs.mu.OZ.AU (Fergus Henderson) writes:
  21. >>clamage@Eng.Sun.COM (Steve Clamage) writes:
  22. >>>
  23. >>>The description of #error says only that it
  24. >>>"causes the implementation to produce a diagnostic message that includes
  25. >>>the specified sequence of preprocessing tokens."
  26. >>
  27. >>Isn't this a bug in the standard?  Doesn't this mean that
  28. >>
  29. >>    #error foobar
  30. >>    int main() { return 0; }
  31. >>
  32. >>is a strictly conforming program?  Yet no compiler I know of will accept it!
  33. >
  34. >It is a strictly conforming program (although we don't use that terminology
  35. >in the C++ standard).
  36.  
  37. OK, so we are agreed so far.
  38.  
  39. >The implementation must tell you what the effect of #error is.
  40.  
  41. What makes you think that?  As far as I can tell, it is not in the
  42. least bit justified by the draft standard.  Here's the complete
  43. description of #error:
  44.  
  45. |   16.5  Error directive                                      [cpp.error]
  46. | 1 A preprocessing directive of the form
  47. |           # error pp-tokensopt new-line
  48. |   causes  the  implementation  to  produce  a  diagnostic  message  that
  49. |   includes the specified sequence of preprocessing tokens.
  50.  
  51. It doesn't say anything about implementation-defined behaviour or the
  52. implementation being required to document anything.
  53.  
  54. >If the effect is to abort compilation, that is allowed.
  55.  
  56. Again, what makes you think that?
  57.  
  58. Is the implementation allowed to abort compilation if it sees a #define?
  59.  
  60. >>Surely the semantics specified for #error should say that it has the effect
  61. >>of making the translation unit ill-formed.
  62. >
  63. >Why?
  64.  
  65. So that you can be sure that a translation unit with #error in it will
  66. not be accepted by any sane implementation.
  67.  
  68. >You can write ill-formed code if you want to. For example:
  69. >    #if undesirable_condition
  70. >    this phrase should not be seen by the compiler
  71. >    #endif
  72.  
  73. But I shouldn't have to.  I'd much rather write just
  74.  
  75.     #if undesirable_condition
  76.     #error "undesirable_condition occurred"
  77.     #endif
  78.  
  79. than
  80.  
  81.     #if undesirable_condition
  82.     this phrase should not be seen by the compiler
  83.     #endif
  84.  
  85. or
  86.  
  87.     #if undesirable_condition
  88.     #error "undesirable_condition occurred"
  89.     this phrase should not be seen by the compiler
  90.     #endif
  91.  
  92. and I would still like to be sure that conforming compilers do not accept
  93. the code if undesirable_condition is true.
  94.  
  95. According to the current wording, conforming compilers are *required*
  96. to accept #error!
  97.  
  98. Obviously this is a mistake; it needs to be fixed.
  99.  
  100. >The #error directive is part of the language, and I think it would be a
  101. >contradiction in terms to say that a valid language construct is ill-formed.
  102.  
  103. The #error itself is not ill-formed; the translation unit containing it is,
  104. unless the #error is skipped via conditional compilation.  There is no
  105. contradiction there.
  106.  
  107. --
  108. Fergus Henderson                 WWW: http://www.cs.mu.oz.au/~fjh
  109. fjh@cs.mu.oz.au                  PGP: finger fjh@128.250.37.3
  110. ---
  111. [ To submit articles: Try just posting with your newsreader.  If that fails,
  112.                       use mailto:std-c++@ncar.ucar.edu
  113.   FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  114.   Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  115.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  116. ]
  117.